package com.sxhuayuan.parking.dto;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.alibaba.druid.util.StringUtils;
import com.alibaba.fastjson.JSON;
import com.sxhuayuan.parking.config.Platform;

/**
 * 无感支付排序
 */
public class PartnerSort implements Serializable {

	private static final long serialVersionUID = 7209579375890364660L;

	private Platform platform;

	private Integer order;

	private Integer isEnabled;

	public Platform getPlatform() {
		return platform;
	}

	public void setPlatform(Platform platform) {
		this.platform = platform;
	}

	public Integer getOrder() {
		return order;
	}

	public void setOrder(Integer order) {
		this.order = order;
	}

	public Integer getIsEnabled() {
		return isEnabled;
	}

	public void setIsEnabled(Integer isEnabled) {
		this.isEnabled = isEnabled;
	}

	static final List<PartnerSort> emptyList = new ArrayList<>();

	public static List<PartnerSort> getPartnersSort(String partnersWeight) {
		if (StringUtils.isEmpty(partnersWeight)) {
			return emptyList;
		}
		return JSON.parseArray(partnersWeight, PartnerSort.class);
	}

	public boolean isEnabled() {
		return this.isEnabled != null && this.isEnabled == 1;
	}
}
